import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2023-04-23
 * Time: 20:25
 */
class Student {

}
public class Test {
    public static void main2(String[] args) {
        Map<Student,Integer> treeMap = new TreeMap<>();
        //Key一定是可以比较的
        treeMap.put(new Student(),1);
        treeMap.put(new Student(),4);
        System.out.println(treeMap);

    }
    public static void main(String[] args) {
        Map<String,Integer> treeMap = new TreeMap<>();
        treeMap.put("abc",4);
        treeMap.put("hello",3);
        treeMap.put("the",8);
        treeMap.put("qi",5);
        treeMap.put("uit",9);
        System.out.println(treeMap.containsValue(4));
        System.out.println(treeMap.containsValue(2));
        System.out.println(treeMap.containsValue(7));
//        System.out.println(treeMap.containsKey("qi"));
//        System.out.println(treeMap.containsKey("world"));
//        System.out.println(treeMap.containsKey("abc"));
//        System.out.println(treeMap);//按照字母顺序进行的排序
//        treeMap.remove("hello");
//        treeMap.remove("the");
//        System.out.println(treeMap);//按照字母顺序进行的排序
//        Integer val = treeMap.get("abc");
//        Integer val1 = treeMap.getOrDefault("hello2",100);
//        System.out.println(val);
//        System.out.println(val1);

//        Set<String> keySet = treeMap.keySet();
//        for (String set: keySet) {
//            System.out.println("key:" + set);
//        }

//        Collection<Integer> values = treeMap.values();
//        for (Integer ret: values) {
//            System.out.println("value:" + ret);
//        }

//        Set<Map.Entry<String,Integer>> set = treeMap.entrySet();
//        for (Map.Entry<String,Integer> entry:set) {
//            System.out.println("key:" + entry.getKey() + " value: "+entry.getValue());
//        }
    }
}
